﻿using Arch.EntityFrameworkCore.UnitOfWork.Collections;
using Common.Lib.Dto;
using Common.Lib.Parameter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Lib.Service
{
    public class LoginService : BaseService<UserDto>, ILoginService
    {
        private readonly HttpRestClient client;

        public LoginService(HttpRestClient client) : base(client, "Login")
        {
            this.client = client;
        }


        public async Task<ApiResponse<UserDto>> LoginAsync(string account, string password)
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.Get;
            request.Route = $"api/Login/Login?account={account}&password={password}";
            return await client.ExecuteAsync<UserDto>(request);
        }

        public async Task<ApiResponse<UserDto>> RegisterAsync(UserDto dto)
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.Post;
            request.Route = $"api/ToDo/Registe";
            return await client.ExecuteAsync<UserDto>(request);
        }
    }

    public interface ILoginService:IBaseService<UserDto>
    {
        Task<ApiResponse<UserDto>> LoginAsync(string account, string password);
        Task<ApiResponse<UserDto>> RegisterAsync(UserDto dto);


    }
}
